package mms

class ApiController {

    def springSecurityService

    def index = { 
        render("index")
    }

    def login = {
        def password = springSecurityService.encodePassword(params.password)
        log.info password
 
        def users = User.findByUsernameAndPassword(params.username , password)
 
        if (users) {
            render "{'authenticationStatus':'true','userName':'${users.username}'}"
        }else{
            render "{'authenticationStatus':'false','userName':'未登录'}"
        } 
//        {"authenticationStatus":"true","userName":"somebody"}

    }

    def live = {

        def companys = Company.findAllByLiveNotEqual("")

//            {"videoPoints":[
//            {"name":"XX药店1","id":"1"},
//            {"name":"XX药店2","id":"2"},
//            {"name":"XX药店3","id":"3"},
//            {"name":"XX药店4","id":"4"},
//            {"name":"XX药店5","id":"5"}]}
 
		 
 
        render(contentType:"text/json") {
     
            videoPoints = array {
                for(com in companys) {
                    name(id : com.id , name: com.name)
                }
            }
        }
    }
 
}
